package org.example;

import org.example.config.KuangConfig;
import org.example.pojo.People;
import org.example.pojo.Student;
import org.example.pojo.User;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main(String[] args) {
    /*    //获取spring对象上下文
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        //我们的对象都在spring中管理，我们要使用就直接取出来就可以了
        User user = context.getBean("user", User.class);*/
        //如果完全使用了配置类方式去做，我们只能通过AnnotationConfig 上下文来来获取容器，通过配置类的class对象加载！
        ApplicationContext context = new AnnotationConfigApplicationContext(KuangConfig.class);
        User getUser = (User) context.getBean("getUser");
        System.out.println(getUser.getName());

        /**
         *输出的结果
         Student{
         name='琴江',
         address=Address{address='西安'},
         books=[三国演义, 水浒传, 红楼梦],
         hobby=[听歌, 敲代码, 看电影],
         card={身份证=52222529997228588525, 地址=河南},
         wife=null,
         info={学号=252255, 性别=男, 姓名=张三}}
         */
    }
}
